<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: fengke
  Date: 2021/8/14
  Time: 10:11 上午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<form action="/employee/list" method="post">
    <!-- 不给默认值默认为null 不能转化为int 会报错 -->
    <input type="hidden" name="currentPage" id="currentPageNum" value="1">
    关键字： <input type="test" name="keyword" value="${qo.keyword}">
    部门： <select name="deptId">
            <option value="-1">全部</option>
            <c:forEach items="${deptList}" var="dept">
                <option value="${dept.id}" ${dept.id == qo.deptId ? 'selected':''}>${dept.name}</option>
            </c:forEach>
          </select>
    <input type="submit" value="查询">
</form>

<table width="500px" cellpadding="0" cellspacing="0" align="center" border="1px">
    <tr>
        <td>员工id</td>
        <td>员工名称</td>
        <td>员工密码</td>
        <td>email</td>
        <td>年龄</td>
        <td>部门名称</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${employeePageResult.data}" var="employee">
        <tr>
            <td>${employee.id}</td>
            <td>${employee.name}</td>
            <td>${employee.password}</td>
            <td>${employee.email}</td>
            <td>${employee.age}</td>
            <td>${employee.dept.name}</td>
            <td>
                <a href="/department/delete?id=${dept.id}">删除</a>
                <a href="/department/input?id=${dept.id}">编辑</a>
            </td>
        </tr>
    </c:forEach>
    <tr align="center">
        <td colspan="9">
            <a href="javascript:void(0)" onclick="goPage(1)">首页</a>
            <a href="javascript:void(0)" onclick="goPage(${employeePageResult.prevPage})">上一页</a>
            <a href="javascript:void(0)" onclick="goPage(${employeePageResult.nextPage})">下一页</a>
            <a href="javascript:void(0)" onclick="goPage(${employeePageResult.totalPage})">尾页</a>
        </td>
    </tr>

</table>

<script type="text/javascript">
    function goPage(currentPage) {
        document.getElementById("currentPageNum").value = currentPage;
        document.forms[0].submit();
    }
</script>

</body>
</html>
